package com.cqc.crm.test;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

import org.junit.Test;

import com.cqc.crm.domain.Student;

public class Demo1 {

	@Test
	public void test1() {
		Student st = new Student();
		//获取父类
		Class<?> superclass = st.getClass().getSuperclass();
		System.out.println(superclass);
		//获取带有泛型的父类
		Type genericSuperclass = st.getClass().getGenericSuperclass();
		//判断父类是否是ParameterizedType
		if(genericSuperclass instanceof ParameterizedType) {
			ParameterizedType type=(ParameterizedType) genericSuperclass;
			//取第一个值
			Class c=(Class) type.getActualTypeArguments()[0];
			System.out.println(c);
		}
	}
}
